/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.ufc.quixada.adrs.comandos.visit;

import br.ufc.quixada.adrs.interfaces.Comando;
import br.ufc.quixada.adrs.service.AdrsService;
import br.ufc.quixada.adrs.util.Paginacao;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

/**
 *
 * @author ismaily
 */
public class CmdVisitCarregarListaAdrs implements Comando {

    public String executa(HttpServletRequest request, HttpServletResponse response) {

        HttpSession session = request.getSession();
        String sPagina = request.getParameter("pagina");

        Long paginaAtual = 1l;
        AdrsService adrsServ = new AdrsService();
        Long offset = 0l;
        //List<Adrs> lista = new AdrsService().getAllAdrs();
        if (sPagina != null) {

            // lista = adrsServ.getPaginaAdrs(0l, Paginacao.LIMIT);
            //} else {
            Long numPag = Long.parseLong(sPagina);
            offset = (numPag - 1) * Paginacao.LIMIT;
            paginaAtual = numPag;
        }
        Paginacao.atualizarListaAdrs(adrsServ, session, paginaAtual, offset);
        return "/visit/visit_gerenciar_adrs.jsp";
    }
}
